using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using QLNhaSach.DAO;
using QLNhaSach.BUS.DTO;

namespace QLNhaSach.BUS.DTO
{
    public class NhanVienBUS
    {
        public static NhanVienDTO DangNhap(NhanVienDTO n)
        {
            DataTable dt = NhanVienDAO.DangNhap(n);
            NhanVienDTO nv = new NhanVienDTO();
            nv.MaNV = Convert.ToInt16(dt.Rows[0][0]);
            nv.HoTen = dt.Rows[0][1].ToString();
            nv.DiaChi = dt.Rows[0][2].ToString();
            nv.GioiTinh = Convert.ToInt16(dt.Rows[0][3]);
            nv.NgaySinh = (DateTime)dt.Rows[0][4];
            nv.DienThoai = dt.Rows[0][5].ToString();
            nv.UserName = dt.Rows[0][6].ToString();
            nv.PassWord = dt.Rows[0][7].ToString();
            nv.TinhTrang = Convert.ToInt16(dt.Rows[0][8]);
            nv.PhanQuyen = Convert.ToInt16(dt.Rows[0][9]);
            return nv;
        }
        //Hien thi thong tin dang nhap
        public static NhanVienDTO HienThiTTCN(int manv)
        {
            NhanVienDTO nv = new NhanVienDTO();
            nv.MaNV = manv;
            DataTable dt = NhanVienDAO.HienThiTTCN(nv);
            nv.MaNV = (int)dt.Rows[0][0];
            nv.HoTen = dt.Rows[0][1].ToString();
            nv.DiaChi = dt.Rows[0][2].ToString();
            nv.GioiTinh = Convert.ToInt16(dt.Rows[0][3]);
            nv.NgaySinh = (DateTime)dt.Rows[0][4];
            nv.DienThoai = dt.Rows[0][5].ToString();
            nv.UserName = dt.Rows[0][6].ToString();
            nv.PassWord = dt.Rows[0][7].ToString();
            nv.TinhTrang = Convert.ToInt16(dt.Rows[0][8]);
            nv.PhanQuyen = Convert.ToInt16(dt.Rows[0][9]);
            return nv;
        }
    }
}
